<template>
  <div class="splash-container">
    <div class="splash-content">
      <!-- Logo区域 -->
      <div class="logo-section">
        <div class="logo-wrapper">
          <img src="/logo.svg" alt="音乐节助手" class="logo" />
        </div>
        <h1 class="app-title">音乐节助手</h1>
        <p class="app-subtitle">您的专属智能向导</p>
      </div>

      <!-- 操作区域 -->
      <div class="action-section">
        <el-button 
          type="primary" 
          size="large" 
          class="enter-btn"
          @click="enterApp"
          :loading="loading"
        >
          立即进入
        </el-button>
        <p class="terms-text">
          点击"立即进入"即表示您同意我们的
          <el-link type="primary" @click="showTerms">服务条款</el-link>
        </p>
      </div>

      <!-- 版本信息 -->
      <div class="version-info">
        <p>Version 1.0.0</p>
      </div>
    </div>

    <!-- 服务条款对话框 -->
    <el-dialog
      v-model="termsVisible"
      title="服务条款"
      width="90%"
      :close-on-click-modal="false"
    >
      <div class="terms-content">
        <h3>音乐节助手服务条款</h3>
        <p>欢迎使用音乐节助手应用！</p>
        <p>本应用致力于为音乐节参与者提供全方位的智能服务体验。</p>
        
        <h4>1. 服务内容</h4>
        <p>我们提供以下服务：</p>
        <ul>
          <li>智能AI助手对话</li>
          <li>场地导航和设施查询</li>
          <li>艺人信息和演出管理</li>
          <li>粉丝互动和投票系统</li>
          <li>个人中心和数据管理</li>
        </ul>

        <h4>2. 用户责任</h4>
        <p>用户在使用本应用时应：</p>
        <ul>
          <li>遵守相关法律法规</li>
          <li>尊重他人权益</li>
          <li>不发布不当内容</li>
          <li>保护个人账户安全</li>
        </ul>

        <h4>3. 隐私保护</h4>
        <p>我们承诺保护用户隐私，不会泄露用户个人信息。</p>
      </div>
      
      <template #footer>
        <el-button @click="termsVisible = false">关闭</el-button>
        <el-button type="primary" @click="acceptTerms">同意并继续</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'

// 响应式数据
const loading = ref(false)
const termsVisible = ref(false)

// 获取路由和用户store
const router = useRouter()
const userStore = useUserStore()

// 进入应用
const enterApp = async () => {
  loading.value = true
  
  try {
    // 检查用户是否已登录
    if (userStore.isLoggedIn) {
      // 已登录，直接跳转到首页
      router.push('/home')
    } else {
      // 未登录，跳转到登录页
      router.push('/login')
    }
  } catch (error) {
    console.error('进入应用失败:', error)
  } finally {
    loading.value = false
  }
}

// 显示服务条款
const showTerms = () => {
  termsVisible.value = true
}

// 同意服务条款
const acceptTerms = () => {
  termsVisible.value = false
  enterApp()
}
</script>

<style lang="scss" scoped>
.splash-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.splash-content {
  text-align: center;
  color: white;
  max-width: 400px;
  width: 100%;
}

.logo-section {
  margin-bottom: 60px;
}

.logo-wrapper {
  margin-bottom: 20px;
}

.logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.2);
  padding: 15px;
  backdrop-filter: blur(10px);
}

.app-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.app-subtitle {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 0;
}

.action-section {
  margin-bottom: 40px;
}

.enter-btn {
  width: 200px;
  height: 50px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 25px;
  background: linear-gradient(135deg, #ff6b6b 0%, #4ecdc4 100%);
  border: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

.terms-text {
  margin-top: 15px;
  font-size: 14px;
  opacity: 0.8;
  line-height: 1.5;
}

.version-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  
  p {
    font-size: 12px;
    opacity: 0.6;
    margin: 0;
  }
}

.terms-content {
  max-height: 400px;
  overflow-y: auto;
  padding: 20px;
  
  h3 {
    color: #333;
    margin-bottom: 20px;
  }
  
  h4 {
    color: #666;
    margin: 20px 0 10px 0;
  }
  
  p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
  }
  
  ul {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
    padding-left: 20px;
    
    li {
      margin-bottom: 5px;
    }
  }
}

// 移动端适配
@media screen and (max-width: 768px) {
  .splash-container {
    padding: 15px;
  }
  
  .app-title {
    font-size: 28px;
  }
  
  .app-subtitle {
    font-size: 14px;
  }
  
  .enter-btn {
    width: 180px;
    height: 45px;
    font-size: 16px;
  }
  
  .logo {
    width: 70px;
    height: 70px;
  }
}
</style> 